package com.bookstore;

import com.bookstore.bean.Compra;
import com.bookstore.db.BookStoreDao;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;

public class BuySuccessfulActivity extends MenuActivity {
	private static final int ACTIVITY_BOOK_LIST = 2;
	private BookStoreDao dao;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.buy_successful);

		if (dao==null){
        	dao = new BookStoreDao(this);
            dao.open();
        }
		
		ImageButton back = (ImageButton) findViewById(R.id.back);
		
		back.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				
				dao.createCompra(BookStoreActivity.compra);
				BookStoreActivity.compra = new Compra();
				
				Intent i = new Intent(BuySuccessfulActivity.this,
						ListCategoryActivity.class);
				startActivityForResult(i, ACTIVITY_BOOK_LIST);
			}
		});
	}
}
